package com.zqs.takeredpackage.job;

import com.zqs.takeredpackage.entity.User;
import com.zqs.takeredpackage.util.UserStoreUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
public class UserJob {

    private static final UserStoreUtil userStoreUtil = new UserStoreUtil();
    //定时打印注册用户信息
    @Scheduled(cron = "30 * * * * ?")
    public void printUserInfo() {
        ArrayList<User> userList = userStoreUtil.getUserList();
        System.out.println("/-------------------------用户列表-----------------------/");
        System.out.println("用户数量：" + userList.size());
        for (User user : userList) {
            System.out.println(user.getUsername() + " " + user.getAccount() + " " + user.getMoney());
        }
    }
}
